package ext.wang.action;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import ext.wang.service.testservices;

/**
 * Servlet implementation class test
 */
public class test extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ServletContext application;
		WebApplicationContext wac;
		application = getServletContext();
		wac = WebApplicationContextUtils.getWebApplicationContext(application);// 获取spring的context
		testservices ss = (testservices) wac.getBean("testservice");
		int count = ss.test();

		System.out.println("trest:" + count);
		response.getWriter().print("trest:" + count);

	}

}
